fix: incorrect cursor position after inserting mention#41074
fix: incorrect cursor position after inserting mention#41074abhinavkrin wants to merge 1 commit into
Conversation
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: ba6ce67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📜 Recent review details⏰ Context from checks skipped due to timeout. (5)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
**/*.spec.ts📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (6)📚 Learning: 2026-03-16T21:50:37.589ZApplied to files:
📚 Learning: 2026-02-24T19:22:48.358ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-03-06T18:10:15.268ZApplied to files:
📚 Learning: 2026-05-06T12:21:44.083ZApplied to files:
🪛 ast-grep (0.44.0)apps/meteor/app/ui-message/client/messageBox/createComposerAPI.spec.ts[warning] 19-19: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first. (dom-content-modification) 🔇 Additional comments (3)
WalkthroughThe message composer now places the cursor at the end of inserted text after ChangesMessage composer cursor fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41074 +/- ##
===========================================
+ Coverage 70.09% 70.12% +0.02%
===========================================
Files 3363 3363
Lines 129711 130068 +357
Branches 22494 22500 +6
===========================================
+ Hits 90922 91208 +286
- Misses 35476 35554 +78
+ Partials 3313 3306 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
When inserting a user/channel mention while the caret is not at the end of the message, the cursor jumped to an incorrect position instead of landing right after the inserted mention, making continued typing and editing awkward.
The root cause was in
replaceTextincreateComposerAPI.ts: after replacing the partial trigger (e.g.@j) with the full mention, the new cursor position was computed from the textarea's live caret position before the replacement (selectionStart) rather than from where the text was actually inserted (selection.start). It also reset the caret back to the original position when a selection existed. This only appeared correct when mentioning at the end of the line, where the overshoot was clamped to the string length.The cursor is now placed at
selection.start + text.length, so it always lands immediately after the inserted mention regardless of where in the message it is inserted. Added unit tests forreplaceTextcovering insertion at the start, middle, and end of a message.Issue(s)
Steps to test or reproduce
@and select a user mentionFurther comments
CORE-2266
Summary by CodeRabbit